<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>省钱控-最新优惠</title>
    <link rel="stylesheet" href="../css/03-saveMnoey.css">
    <link rel="stylesheet" href="../css/Common.css">
    <link rel="stylesheet" href="../css/media.css">
    <link rel="stylesheet" type="text/css" href="../font/iconfont.css">
</head>
<body>
    <!-- 头部 -->
    <header>
        <a href="javascript:;"><span class="iconfont icon-fanhui"></span></a>
        <span>省钱控 - 最新优惠</span>
        <a href="javascript:;"><img src="../images/header_app.png" alt=""></a>
    </header>
    <!-- 商品列表 -->
   <div class="product clearfix">

        
    </div>
    <!-- 页脚 -->
    <footer>
            <ul class="pagination">

            </ul> 
        <ul class="dl">
            <li><a href="javascript:;">登录</a></li>
            <li><a href="javascript:;">注册</a></li>
            <li><a id="goTop" href="javascript:;"><span  ></span>返回顶部</a></li>
        </ul>
        <div class="way">
            <span>手机AAP下载</span><span>慢慢买手机版</span><span>-掌上比价平台m.manmanbuy.com</span>
        </div>
    </footer>
    <!-- <script src="../lib/js/bootstrap.js"></script> -->
    <script src="../lib/jquery-1.12.4.min.js"></script>
</body>
</html>
<script src="../js/03-saveMoney.js"></script>
<script src="../lib/twbs-pagination/jquery.twbsPagination.js"></script>
<script src="../lib/template.js"></script>
<script type="text/template" id="productList">
    {{each result as val key }}
       <div class="content clearfix">
            <div class="product_left">
                    <a href="3.1-details.html?id={{val.productId}}">{{val.productImgSm}}</a>
                </div>
                <div class="product_right">
                    <div class="product_rp">
                        {{val.productName}}
                        <span class="product_cheap">{{val.productPinkage}}</span>     
                    </div>
                    
                    <div class="product_shop">
                        <span class="mall">{{val.productFrom}}</span> | 
                        <span class="time">{{val.productTime}}</span>
                        <span></span>
                        <span class="comment">{{val.productComCount}}</span>
                    </div>
                </div>
       </div>
    {{/each}}
</script>
<script>
    rander();
    // var pageid=0;
   function rander(pageid){
    $.ajax({
            url:'http://193.112.55.79:9090/api/getmoneyctrl',
            type:'get',
            dataType:'json',
            data:{
                pageid:pageid,
            },
            success:function (res) {
                template.config("escape", false);
                var str=template('productList',res);
                console.log(res);
                
                //动态渲染页面
            $('.product').html(str);
            // count=res.totalCount/res.pageSize;
            Pagination(res.totalCount/res.pagesize,pageid);    
        }
})
   }

//实现分页
function Pagination(totalCount,pageid){

    $('.pagination').twbsPagination({
        totalPages: totalCount, //总的页面数
        visiblePages: 3, //当前显示的页码数
        first:"首页",
        prev:"上一页",
        next:"下一页",
        last:"尾页",
        initiateStartPageClick:false,//清除初始化时打印的页码
        onPageClick: function (event, page ) { 
            // $('#page-content').text('Page ' + page);
            $.ajax({
                url:'http://193.112.55.79:9090/api/getmoneyctrl',
                type:'get',
                dataType:'json',
                data:{
                    page:page,
                },
                success:function(res){
                    
                    rander(page);
                //     var str=template('productList',res);  
                // //动态渲染页面
                //     $('.product').html(str);
                    
                }
            })
        }
        
    });
}


</script>